#ifndef _LPC214X_H
#define _LPC214X_H

//-- Flash Accelerator Module (MAM)
#define rMAMCR           (*((volatile unsigned char *) 0xE01FC000))
#define rMAMTIM          (*((volatile unsigned char *) 0xE01FC004))
#define rMEMMAP          (*((volatile unsigned char *) 0xE01FC040))

//-- Watchdog Timer
#define rWDMOD           (*((volatile unsigned char *) 0xE0000000))
#define rWDTC            (*((volatile unsigned long *) 0xE0000004))
#define rWDFEED          (*((volatile unsigned char *) 0xE0000008))
#define rWDTV            (*((volatile unsigned long *) 0xE000000C))

//-- Timer 0
#define rT0IR            (*((volatile unsigned long *) 0xE0004000))
#define rT0TCR           (*((volatile unsigned long *) 0xE0004004))
#define rT0TC            (*((volatile unsigned long *) 0xE0004008))
#define rT0PR            (*((volatile unsigned long *) 0xE000400C))
#define rT0PC            (*((volatile unsigned long *) 0xE0004010))
#define rT0MCR           (*((volatile unsigned long *) 0xE0004014))
#define rT0MR0           (*((volatile unsigned long *) 0xE0004018))
#define rT0MR1           (*((volatile unsigned long *) 0xE000401C))
#define rT0MR2           (*((volatile unsigned long *) 0xE0004020))
#define rT0MR3           (*((volatile unsigned long *) 0xE0004024))
#define rT0CCR           (*((volatile unsigned long *) 0xE0004028))
#define rT0CR0           (*((volatile unsigned long *) 0xE000402C))
#define rT0CR1           (*((volatile unsigned long *) 0xE0004030))
#define rT0CR2           (*((volatile unsigned long *) 0xE0004034))
#define rT0CR3           (*((volatile unsigned long *) 0xE0004038))
#define rT0EMR           (*((volatile unsigned long *) 0xE000403C))
#define rT0CTCR          (*((volatile unsigned long *) 0xE0004070))

//-- Timer 1
#define rT1IR            (*((volatile unsigned long *) 0xE0008000))
#define rT1TCR           (*((volatile unsigned long *) 0xE0008004))
#define rT1TC            (*((volatile unsigned long *) 0xE0008008))
#define rT1PR            (*((volatile unsigned long *) 0xE000800C))
#define rT1PC            (*((volatile unsigned long *) 0xE0008010))
#define rT1MCR           (*((volatile unsigned long *) 0xE0008014))
#define rT1MR0           (*((volatile unsigned long *) 0xE0008018))
#define rT1MR1           (*((volatile unsigned long *) 0xE000801C))
#define rT1MR2           (*((volatile unsigned long *) 0xE0008020))
#define rT1MR3           (*((volatile unsigned long *) 0xE0008024))
#define rT1CCR           (*((volatile unsigned long *) 0xE0008028))
#define rT1CR0           (*((volatile unsigned long *) 0xE000802C))
#define rT1CR1           (*((volatile unsigned long *) 0xE0008030))
#define rT1CR2           (*((volatile unsigned long *) 0xE0008034))
#define rT1CR3           (*((volatile unsigned long *) 0xE0008038))
#define rT1EMR           (*((volatile unsigned long *) 0xE000803C))
#define rT1CTCR          (*((volatile unsigned long *) 0xE0008070))

//-- UART0
#define rU0RBR           (*((volatile unsigned char *) 0xE000C000))
#define rU0THR           (*((volatile unsigned char *) 0xE000C000))
#define rU0IER           (*((volatile unsigned long *) 0xE000C004))
#define rU0IIR           (*((volatile unsigned long *) 0xE000C008))
#define rU0FCR           (*((volatile unsigned char *) 0xE000C008))
#define rU0LCR           (*((volatile unsigned char *) 0xE000C00C))
#define rU0MCR           (*((volatile unsigned char *) 0xE000C010))
#define rU0LSR           (*((volatile unsigned char *) 0xE000C014))
#define rU0MSR           (*((volatile unsigned char *) 0xE000C018))
#define rU0SCR           (*((volatile unsigned char *) 0xE000C01C))
#define rU0DLL           (*((volatile unsigned char *) 0xE000C000))
#define rU0DLM           (*((volatile unsigned char *) 0xE000C004))
#define rU0ACR           (*((volatile unsigned long *) 0xE000C020))
#define rU0FDR           (*((volatile unsigned long *) 0xE000C028))
#define rU0TER           (*((volatile unsigned char *) 0xE000C030))

//-- UART1
#define rU1RBR           (*((volatile unsigned char *) 0xE0010000))
#define rU1THR           (*((volatile unsigned char *) 0xE0010000))
#define rU1IER           (*((volatile unsigned long *) 0xE0010004))
#define rU1IIR           (*((volatile unsigned long *) 0xE0010008))
#define rU1FCR           (*((volatile unsigned char *) 0xE0010008))
#define rU1LCR           (*((volatile unsigned char *) 0xE001000C))
#define rU1MCR           (*((volatile unsigned char *) 0xE0010010))
#define rU1LSR           (*((volatile unsigned char *) 0xE0010014))
#define rU1MSR           (*((volatile unsigned char *) 0xE0010018))
#define rU1SCR           (*((volatile unsigned char *) 0xE001001C))
#define rU1DLL           (*((volatile unsigned char *) 0xE0010000))
#define rU1DLM           (*((volatile unsigned char *) 0xE0010004))
#define rU1ACR           (*((volatile unsigned long *) 0xE0010020))
#define rU1FDR           (*((volatile unsigned long *) 0xE0010028))
#define rU1TER           (*((volatile unsigned char *) 0xE0010030))

//-- I2C 0
#define rI2C0CONSET      (*((volatile unsigned char *) 0xE001C000))
#define rI2C0STAT        (*((volatile unsigned char *) 0xE001C004))
#define rI2C0DAT         (*((volatile unsigned char *) 0xE001C008))
#define rI2C0ADR         (*((volatile unsigned char *) 0xE001C00C))
#define rI2C0SCLH        (*((volatile unsigned short*) 0xE001C010))
#define rI2C0SCLL        (*((volatile unsigned short*) 0xE001C014))
#define rI2C0CONCLR      (*((volatile unsigned char *) 0xE001C018))

//-- I2C 1
#define rI2C1CONSET      (*((volatile unsigned char *) 0xE005C000))
#define rI2C1STAT        (*((volatile unsigned char *) 0xE005C004))
#define rI2C1DAT         (*((volatile unsigned char *) 0xE005C008))
#define rI2C1ADR         (*((volatile unsigned char *) 0xE005C00C))
#define rI2C1SCLH        (*((volatile unsigned short*) 0xE005C010))
#define rI2C1SCLL        (*((volatile unsigned short*) 0xE005C014))
#define rI2C1CONCLR      (*((volatile unsigned char *) 0xE005C018))

//-- SPI0
#define rS0SPCR          (*((volatile unsigned short*) 0xE0020000))
#define rS0SPSR          (*((volatile unsigned char *) 0xE0020004))
#define rS0SPDR          (*((volatile unsigned short*) 0xE0020008))
#define rS0SPCCR         (*((volatile unsigned char *) 0xE002000C))
#define rS0SPINT         (*((volatile unsigned char *) 0xE002001C))

//-- SSP
#define rSSPCR0          (*((volatile unsigned short*) 0xE0068000))
#define rSSPCR1          (*((volatile unsigned char *) 0xE0068004))
#define rSSPDR           (*((volatile unsigned short*) 0xE0068008))
#define rSSPSR           (*((volatile unsigned char *) 0xE006800C))
#define rSSPCPSR         (*((volatile unsigned char *) 0xE0068010))
#define rSSPIMSC         (*((volatile unsigned char *) 0xE0068014))
#define rSSPRIS          (*((volatile unsigned char *) 0xE0068018))
#define rSSPMIS          (*((volatile unsigned char *) 0xE006801C))
#define rSSPICR          (*((volatile unsigned char *) 0xE0068020))

//-- Real Time Clock (RTC)
#define rILR             (*((volatile unsigned char *) 0xE0024000))
#define rCTC             (*((volatile unsigned short*) 0xE0024004))
#define rCCR             (*((volatile unsigned char *) 0xE0024008))
#define rCIIR            (*((volatile unsigned char *) 0xE002400C))
#define rAMR             (*((volatile unsigned char *) 0xE0024010))
#define rCTIME0          (*((volatile unsigned long *) 0xE0024014))
#define rCTIME1          (*((volatile unsigned long *) 0xE0024018))
#define rCTIME2          (*((volatile unsigned long *) 0xE002401C))
#define rSEC             (*((volatile unsigned char *) 0xE0024020))
#define rMIN             (*((volatile unsigned char *) 0xE0024024))
#define rHOUR            (*((volatile unsigned char *) 0xE0024028))
#define rDOM             (*((volatile unsigned char *) 0xE002402C))
#define rDOW             (*((volatile unsigned char *) 0xE0024030))
#define rDOY             (*((volatile unsigned short*) 0xE0024034))
#define rMONTH           (*((volatile unsigned char *) 0xE0024038))
#define rYEAR            (*((volatile unsigned short*) 0xE002403C))
#define rALSEC           (*((volatile unsigned char *) 0xE0024060))
#define rALMIN           (*((volatile unsigned char *) 0xE0024064))
#define rALHOUR          (*((volatile unsigned char *) 0xE0024068))
#define rALDOM           (*((volatile unsigned char *) 0xE002406C))
#define rALDOW           (*((volatile unsigned char *) 0xE0024070))
#define rALDOY           (*((volatile unsigned short*) 0xE0024074))
#define rALMON           (*((volatile unsigned char *) 0xE0024078))
#define rALYEAR          (*((volatile unsigned short*) 0xE002407C))
#define rPREINT          (*((volatile unsigned short*) 0xE0024080))
#define rPREFRAC         (*((volatile unsigned short*) 0xE0024084))

//-- General Purpose Input/Output (GPIO)
#define rIOPIN0          (*((volatile unsigned long *) 0xE0028000))
#define rIOSET0          (*((volatile unsigned long *) 0xE0028004))
#define rIODIR0          (*((volatile unsigned long *) 0xE0028008))
#define rIOCLR0          (*((volatile unsigned long *) 0xE002800C))
#define rIOPIN1          (*((volatile unsigned long *) 0xE0028010))
#define rIOSET1          (*((volatile unsigned long *) 0xE0028014))
#define rIODIR1          (*((volatile unsigned long *) 0xE0028018))
#define rIOCLR1          (*((volatile unsigned long *) 0xE002801C))
#define rIO0PIN          (*((volatile unsigned long *) 0xE0028000))
#define rIO0SET          (*((volatile unsigned long *) 0xE0028004))
#define rIO0DIR          (*((volatile unsigned long *) 0xE0028008))
#define rIO0CLR          (*((volatile unsigned long *) 0xE002800C))
#define rIO1PIN          (*((volatile unsigned long *) 0xE0028010))
#define rIO1SET          (*((volatile unsigned long *) 0xE0028014))
#define rIO1DIR          (*((volatile unsigned long *) 0xE0028018))
#define rIO1CLR          (*((volatile unsigned long *) 0xE002801C))
#define rFIO0DIR         (*((volatile unsigned long *) 0x3FFFC000))
#define rFIO0MASK        (*((volatile unsigned long *) 0x3FFFC010))
#define rFIO0PIN         (*((volatile unsigned long *) 0x3FFFC014))
#define rFIO0SET         (*((volatile unsigned long *) 0x3FFFC018))
#define rFIO0CLR         (*((volatile unsigned long *) 0x3FFFC01C))
#define rFIO1DIR         (*((volatile unsigned long *) 0x3FFFC020))
#define rFIO1MASK        (*((volatile unsigned long *) 0x3FFFC030))
#define rFIO1PIN         (*((volatile unsigned long *) 0x3FFFC034))
#define rFIO1SET         (*((volatile unsigned long *) 0x3FFFC038))
#define rFIO1CLR         (*((volatile unsigned long *) 0x3FFFC03C))

//-- Pin Connect Block
#define rPINSEL0         (*((volatile unsigned long *) 0xE002C000))
#define rPINSEL1         (*((volatile unsigned long *) 0xE002C004))
#define rPINSEL2         (*((volatile unsigned long *) 0xE002C014))

//-- Phase Locked Loop 0 (PLL0)
#define rPLL0CON         (*((volatile unsigned char *) 0xE01FC080))
#define rPLL0CFG         (*((volatile unsigned char *) 0xE01FC084))
#define rPLL0STAT        (*((volatile unsigned short*) 0xE01FC088))
#define rPLL0FEED        (*((volatile unsigned char *) 0xE01FC08C))

//-- Pharse Locked Loop 1 (PLL1)
#define rPLL1CON         (*((volatile unsigned char *) 0xE01FC0A0))
#define rPLL1CFG         (*((volatile unsigned char *) 0xE01FC0A4))
#define rPLL1STAT        (*((volatile unsigned short*) 0xE01FC0A8))
#define rPLL1FEED        (*((volatile unsigned char *) 0xE01FC0AC))

//-- VPBr Divider
#define rVPBDIV          (*((volatile unsigned char *) 0xE01FC100))

//-- Power Control
#define rPCON            (*((volatile unsigned char *) 0xE01FC0C0))
#define rPCONP           (*((volatile unsigned int *) 0xE01FC0C4))

//-- External Interrupts
#define rEXTINT          (*((volatile unsigned char *) 0xE01FC140))
#define rINTWAKE         (*((volatile unsigned short*) 0xE01FC144))
#define rEXTMODE         (*((volatile unsigned char *) 0xE01FC148))
#define rEXTPOLAR        (*((volatile unsigned char *) 0xE01FC14C))
//-- Reset
#define rRSID            (*((volatile unsigned char *) 0xE01FC180))

//-- Code Security / Debugging
#define rCSPR            (*((volatile unsigned char *) 0xE01FC184))

//-- System Control Miscellaneous
#define rSCS             (*((volatile unsigned long *) 0xE01FC1A0))

//-- ADC0 (AD0)
#define rAD0CR           (*((volatile unsigned long *) 0xE0034000))
#define rAD0GDR          (*((volatile unsigned long *) 0xE0034004))
#define rAD0STAT         (*((volatile unsigned long *) 0xE0034030))
#define rAD0INTEN        (*((volatile unsigned long *) 0xE003400C))
#define rAD0DR0          (*((volatile unsigned long *) 0xE0034010))
#define rAD0DR1          (*((volatile unsigned long *) 0xE0034014))
#define rAD0DR2          (*((volatile unsigned long *) 0xE0034018))
#define rAD0DR3          (*((volatile unsigned long *) 0xE003401C))
#define rAD0DR4          (*((volatile unsigned long *) 0xE0034020))
#define rAD0DR5          (*((volatile unsigned long *) 0xE0034024))
#define rAD0DR6          (*((volatile unsigned long *) 0xE0034028))
#define rAD0DR7          (*((volatile unsigned long *) 0xE003402C))

//-- ADC1 (AD1)
#define rAD1CR           (*((volatile unsigned long *) 0xE0060000))
#define rAD1GDR          (*((volatile unsigned long *) 0xE0060004))
#define rAD1STAT         (*((volatile unsigned long *) 0xE0060030))
#define rAD1INTEN        (*((volatile unsigned long *) 0xE006000C))
#define rAD1DR0          (*((volatile unsigned long *) 0xE0060010))
#define rAD1DR1          (*((volatile unsigned long *) 0xE0060014))
#define rAD1DR2          (*((volatile unsigned long *) 0xE0060018))
#define rAD1DR3          (*((volatile unsigned long *) 0xE006001C))
#define rAD1DR4          (*((volatile unsigned long *) 0xE0060020))
#define rAD1DR5          (*((volatile unsigned long *) 0xE0060024))
#define rAD1DR6          (*((volatile unsigned long *) 0xE0060028))
#define rAD1DR7          (*((volatile unsigned long *) 0xE006002C))

//-- ADC Global
#define rADGSR           (*((volatile unsigned long *) 0xE0034008))

//-- DAC
#define rDACR            (*((volatile unsigned long *) 0xE006C000))

//-- PWM
#define rPWMIR           (*((volatile unsigned long *) 0xE0014000))
#define rPWMTCR          (*((volatile unsigned long *) 0xE0014004))
#define rPWMTC           (*((volatile unsigned long *) 0xE0014008))
#define rPWMPR           (*((volatile unsigned long *) 0xE001400C))
#define rPWMPC           (*((volatile unsigned long *) 0xE0014010))
#define rPWMMCR          (*((volatile unsigned long *) 0xE0014014))
#define rPWMMR0          (*((volatile unsigned long *) 0xE0014018))
#define rPWMMR1          (*((volatile unsigned long *) 0xE001401C))
#define rPWMMR2          (*((volatile unsigned long *) 0xE0014020))
#define rPWMMR3          (*((volatile unsigned long *) 0xE0014024))
#define rPWMMR4          (*((volatile unsigned long *) 0xE0014040))
#define rPWMMR5          (*((volatile unsigned long *) 0xE0014044))
#define rPWMMR6          (*((volatile unsigned long *) 0xE0014048))
#define rPWMPCR          (*((volatile unsigned long *) 0xE001404C))
#define rPWMLER          (*((volatile unsigned long *) 0xE0014050))

//-- USB Controller
#define rUSBIntSt        (*((volatile unsigned long *) 0xE01FC1C0))
#define rUSBDevIntSt     (*((volatile unsigned long *) 0xE0090000))
#define rUSBDevIntEn     (*((volatile unsigned long *) 0xE0090004))
#define rUSBDevIntClr    (*((volatile unsigned long *) 0xE0090008))
#define rUSBDevIntSet    (*((volatile unsigned long *) 0xE009000C))
#define rUSBDevIntPri    (*((volatile unsigned char *) 0xE009002C))
#define rUSBEpIntSt      (*((volatile unsigned long *) 0xE0090030))
#define rUSBEpIntEn      (*((volatile unsigned long *) 0xE0090034))
#define rUSBEpIntClr     (*((volatile unsigned long *) 0xE0090038))
#define rUSBEpIntSet     (*((volatile unsigned long *) 0xE009003C))
#define rUSBEpIntPri     (*((volatile unsigned long *) 0xE0090040))
#define rUSBReEp         (*((volatile unsigned long *) 0xE0090044))
#define rUSBEpInd        (*((volatile unsigned long *) 0xE0090048))
#define rUSBMaxPSize     (*((volatile unsigned long *) 0xE009004C))
#define rUSBRxData       (*((volatile unsigned long *) 0xE0090018))
#define rUSBRxPLen       (*((volatile unsigned long *) 0xE0090020))
#define rUSBTxData       (*((volatile unsigned long *) 0xE009001C))
#define rUSBTxPLen       (*((volatile unsigned long *) 0xE0090024))
#define rUSBCtrl         (*((volatile unsigned long *) 0xE0090028))
#define rUSBCmdCode      (*((volatile unsigned long *) 0xE0090010))
#define rUSBCmdData      (*((volatile unsigned long *) 0xE0090014))
#define rUSBDMARSt       (*((volatile unsigned long *) 0xE0090050))
#define rUSBDMARClr      (*((volatile unsigned long *) 0xE0090054))
#define rUSBDMARSet      (*((volatile unsigned long *) 0xE0090058))
#define rUSBUDCAH        (*((volatile unsigned long *) 0xE0090080))
#define rUSBEpDMASt      (*((volatile unsigned long *) 0xE0090084))
#define rUSBEpDMAEn      (*((volatile unsigned long *) 0xE0090088))
#define rUSBEpDMADis     (*((volatile unsigned long *) 0xE009008C))
#define rUSBDMAIntSt     (*((volatile unsigned long *) 0xE0090090))
#define rUSBDMAIntEn     (*((volatile unsigned long *) 0xE0090094))
#define rUSBEoTIntSt     (*((volatile unsigned long *) 0xE00900A0))
#define rUSBEoTIntClr    (*((volatile unsigned long *) 0xE00900A4))
#define rUSBEoTIntSet    (*((volatile unsigned long *) 0xE00900A8))
#define rUSBNDDRIntSt    (*((volatile unsigned long *) 0xE00900AC))
#define rUSBNDDRIntClr   (*((volatile unsigned long *) 0xE00900B0))
#define rUSBNDDRIntSet   (*((volatile unsigned long *) 0xE00900B4))
#define rUSBSysErrIntSt  (*((volatile unsigned long *) 0xE00900B8))
#define rUSBSysErrIntClr (*((volatile unsigned long *) 0xE00900BC))
#define rUSBSysErrIntSet (*((volatile unsigned long *) 0xE00900C0))

//-- Vectored Interrupt Controller (VIC)
#define VICIRQStatus    (*((volatile unsigned long *) 0xFFFFF000))
#define VICFIQStatus    (*((volatile unsigned long *) 0xFFFFF004))
#define VICRawIntr      (*((volatile unsigned long *) 0xFFFFF008))
#define VICIntSelect    (*((volatile unsigned long *) 0xFFFFF00C))
#define VICIntEnable    (*((volatile unsigned long *) 0xFFFFF010))
#define VICIntEnClr     (*((volatile unsigned long *) 0xFFFFF014))
#define VICSoftInt      (*((volatile unsigned long *) 0xFFFFF018))
#define VICSoftIntClr   (*((volatile unsigned long *) 0xFFFFF01C))
#define VICProtection   (*((volatile unsigned long *) 0xFFFFF020))
#define VICVectAddr     (*((volatile unsigned long *) 0xFFFFF030))
#define VICDefVectAddr  (*((volatile unsigned long *) 0xFFFFF034))
#define VICVectAddr0    (*((volatile unsigned long *) 0xFFFFF100))
#define VICVectAddr1    (*((volatile unsigned long *) 0xFFFFF104))
#define VICVectAddr2    (*((volatile unsigned long *) 0xFFFFF108))
#define VICVectAddr3    (*((volatile unsigned long *) 0xFFFFF10C))
#define VICVectAddr4    (*((volatile unsigned long *) 0xFFFFF110))
#define VICVectAddr5    (*((volatile unsigned long *) 0xFFFFF114))
#define VICVectAddr6    (*((volatile unsigned long *) 0xFFFFF118))
#define VICVectAddr7    (*((volatile unsigned long *) 0xFFFFF11C))
#define VICVectAddr8    (*((volatile unsigned long *) 0xFFFFF120))
#define VICVectAddr9    (*((volatile unsigned long *) 0xFFFFF124))
#define VICVectAddr10   (*((volatile unsigned long *) 0xFFFFF128))
#define VICVectAddr11   (*((volatile unsigned long *) 0xFFFFF12C))
#define VICVectAddr12   (*((volatile unsigned long *) 0xFFFFF130))
#define VICVectAddr13   (*((volatile unsigned long *) 0xFFFFF134))
#define VICVectAddr14   (*((volatile unsigned long *) 0xFFFFF138))
#define VICVectAddr15   (*((volatile unsigned long *) 0xFFFFF13C))
#define VICVectCntl0    (*((volatile unsigned long *) 0xFFFFF200))
#define VICVectCntl1    (*((volatile unsigned long *) 0xFFFFF204))
#define VICVectCntl2    (*((volatile unsigned long *) 0xFFFFF208))
#define VICVectCntl3    (*((volatile unsigned long *) 0xFFFFF20C))
#define VICVectCntl4    (*((volatile unsigned long *) 0xFFFFF210))
#define VICVectCntl5    (*((volatile unsigned long *) 0xFFFFF214))
#define VICVectCntl6    (*((volatile unsigned long *) 0xFFFFF218))
#define VICVectCntl7    (*((volatile unsigned long *) 0xFFFFF21C))
#define VICVectCntl8    (*((volatile unsigned long *) 0xFFFFF220))
#define VICVectCntl9    (*((volatile unsigned long *) 0xFFFFF224))
#define VICVectCntl10   (*((volatile unsigned long *) 0xFFFFF228))
#define VICVectCntl11   (*((volatile unsigned long *) 0xFFFFF22C))
#define VICVectCntl12   (*((volatile unsigned long *) 0xFFFFF230))
#define VICVectCntl13   (*((volatile unsigned long *) 0xFFFFF234))
#define VICVectCntl14   (*((volatile unsigned long *) 0xFFFFF238))
#define VICVectCntl15   (*((volatile unsigned long *) 0xFFFFF23C))

#endif  // __LPC214x_H
